package primalgorithms.array;

public class _08MoveZeroes {
    public static void moveZeroes(int[] nums) {
        //在不复制数组的条件下将所有0移动到数组末尾
        int len = nums.length;
        if(len == 0){
            return;
        }
        //设置下标计数器
        int count = 0;
        for (int i = 0;i < len;i++){
            if(nums[i] != 0){
                nums[count++] = nums[i];
            }
        }
        for (int i = count;i < len;i++){
            nums[i] = 0;
        }
    }
}
